<?php

//防止恶意调用
if (!defined('IN_MOD'))
{
    die('Hacking attempt');
}

// 获取平台与店铺基本信息
function getplatshopbaseinfo($shopid=0,$shopinfo=array())
{
	$shopbase = array();
	
	if($shopid > 0)
	{
		if(empty($shopinfo))
		{
			$modulewhere=array();
			$modulewhere["tablename"]="fastxcms_portal_post_supplier";
			$modulewhere["dataid"]=$shopid;
			$modulewhere["dataidname"]="supplier_id";
			$shopinfo=modulepara("datainfo",$modulewhere);
			$parameterinfo = getmoduleparameter($shopinfo['id'], 172);
			if($parameterinfo)
			{
				$shopinfo = hbarray($shopinfo,$parameterinfo);
			}
			$shopinfo['shop_name'] = $shopinfo['post_title'];
		}
		$shopbase['shopid'] = $shopinfo['supplier_id'];
		$shopbase['shop_name'] = $shopinfo['shop_name'];
		$shopbase['shop_url'] = "#shop".$shopinfo['supplier_id'];
	}else{
		$shopbase['shopid'] = 0;
		$shopbase['shop_name'] = "平台自营";
		$shopbase['shop_url'] = "/";
	}
	
	return $shopbase;
}	

// 付款成功后会员帐户操作
// 付完款后操作 正式请在付完款后设置支付状态之前执行以下代码（先扣款帐户再设置支付状态，避免设置支付状态后未扣款BUG）
function setMemberPayOpeater($orderID)
{	
	global $configmember,$configbase;
	
	// 获取当前订单信息
	$modulewhere=array();
	$modulewhere["tablename"]="fastxcms_portal_post_order";
	$modulewhere["dataid"]=$orderID;
	$modulewhere["dataidname"]="id";
	$modulewhere["where"]="";
	$modulewhere["topid"]=109;
	$orderInfo=modulepara("datainfo",$modulewhere);
	
	// 设置已使用优惠券
	$moduledata = array();
	$moduledata['tablename'] = "fastxcms_user_coupon";
	$moduledata['data'] = array('status' => 1);
	$moduledata['dataidname'] = 'id';
	$moduledata['dataid'] = $orderInfo['useyhj'];
	modulepara("updatedata",$moduledata);
	
	// 使用积分抵扣
	$useintegral = $orderInfo['dkprice'] * $configbase['shopconfig']['integralratio'];// 计算当前使用积分
	if(!empty($useintegral))
	{
		updatemembermoney($configmember['id'],$useintegral,2,'-');
	}
		
	// 购买商品赠送积分
	if(!empty($orderInfo['giveintegral']))
	{
		updatemembermoney($configmember['id'],$orderInfo['giveintegral'],2);
		
		// 赠送积分记录
		insertintegrallog($orderInfo['giveintegral']);
	}
}
?>